<?php
/*
//Models
//use for reference t_approval
//author : fajar nugroho
*/
class mdl_t_approval extends CI_Model{

	function __construct(){
		//call to model constuctor
		parent::__construct();
	}

	function get_all(){
		$this->db->flush_cache();
		$this->db->select('*');
		$this->db->from('t_approval');
		return $this->db->get();
	}

	function get_by_id($id){
		$this->db->flush_cache();
		$this->db->select('*');
		$this->db->from('t_approval');
		$this->db->where('id', $id);

		return $this->db->get();
	}

	function insert($data){
		$this->db->flush_cache();
		$this->db->set('id_approval', $data['id_approval']);
		$this->db->set('approval', $data['approval']);
		$result = $this->db->insert('t_approval');

		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}

	}

	function insert_log($data){
		$this->db->flush_cache();
		$this->db->set('id_surat', $data['id_surat']);
		$this->db->set('userid', $data['userid']);
		$this->db->set('isi_surat', $data['isi_surat']);
		$this->db->set('kirim_ke', $data['kirim_ke']);
		$this->db->set('date', $data['date']);
		$this->db->set('time', $data['time']);
		$this->db->set('gen_log_surat', $data['gen_log_surat']);

		$result = $this->db->insert('log_surat_keluar');

		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
	}


	function update_log($data){
		$this->db->flush_cache();
		$this->db->set('kirim_ke', $data['kirim_ke']);

		$this->db->where('id', $data['id']);
		$this->db->where('userid', $data['userid']);
		$result = $this->db->update('log_surat_keluar');

		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
	}

	function update_revision($data){
		$this->db->flush_cache();
		$this->db->set('is_revision', '1');
		$this->db->set('id_surat', $data['id_surat']);

		$this->db->where('id', $data['id']);
		$result = $this->db->update('log_surat_keluar');
		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
	}


}


?>